package com.mingqijia.gassafety.authority.api.web.facade;

import com.mingqijia.gassafety.authority.api.req.manager.ManagerLoginReqDTO;
import com.mingqijia.gassafety.authority.api.resp.manager.UserProfileRespDTO;
import com.mingqijia.gassafety.authority.api.resp.resource.ResourceLiteRespDTO;
import com.mingqijia.gassafety.shared.constant.Constants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
import java.util.concurrent.ExecutionException;

/**
 * 权限管理接口
 * @author Damon S.
 * @version v1.0.1
 * @date 2020年05月27日 22:45
 */
@Api(tags = "控制台--登录")
@RequestMapping(value = "/console/v1/oauth", produces = MediaType.APPLICATION_JSON_VALUE)
public interface AuthorityManageFacade {

    @PostMapping("/token")
    @ApiOperation(value = "生成token", notes = "返回token")
    default String genToken(@RequestBody@Valid ManagerLoginReqDTO req) {
        return Constants.STR_EMPTY;
    }

    @PostMapping("/token/refresh/ben")
    @ApiOperation(value = "刷新ben token", notes = "刷新ben token")
    String refreshBenToken();

    @GetMapping("/captcha")
    @ApiImplicitParam(name = "username", value = "账户名", dataType = "String")
    @ApiOperation(value = "验证码", notes = "返回验证码")
    String genCaptcha(@RequestParam("username")String username, HttpServletResponse response);

    @GetMapping("/profile")
    @ApiOperation(value = "用户信息", notes = "返回用户信息")
    UserProfileRespDTO getUserProfile(HttpServletRequest request);

    @GetMapping("/{workingSpId}/authorities")
    @ApiImplicitParam(name = "workingSpId", value = "当前操作SP_ID", dataType = "String")
    @ApiOperation(value = "用户在当前操作企业的菜单权限", notes = "返回用户权限")
    List<ResourceLiteRespDTO> getAuthorizedRes(@PathVariable String workingSpId) throws Exception;
}
